
var initFoodOrderInfoBean;
var getFoodOrderInfoBeanFromOpenPage = function(){
	var foodorderinfoBean = {};
	foodorderinfoBean.id = jQuery('#idEditor').val();
	
	foodorderinfoBean.userId = jQuery('#userIdEditor').val();
	if(!foodorderinfoBean.userId){
		$.ligerDialog.error("请输入订餐用户!");
		return null;
	}	foodorderinfoBean.areaId = jQuery('#areaIdEditor').val();
	if(!foodorderinfoBean.areaId){
		$.ligerDialog.error("请输入大厦!");
		return null;
	}	foodorderinfoBean.shopId = jQuery('#shopIdEditor').val();
	foodorderinfoBean.foodId = jQuery('#foodIdEditor').val();
	if(!foodorderinfoBean.foodId){
		$.ligerDialog.error("请输入餐品!");
		return null;
	}	foodorderinfoBean.num = jQuery('#numEditor').val();
	if(!foodorderinfoBean.num){
		$.ligerDialog.error("请输入份数!");
		return null;
	}	foodorderinfoBean.onePrice = jQuery('#onePriceEditor').val();
	if(!foodorderinfoBean.onePrice){
		$.ligerDialog.error("请输入单份价格!");
		return null;
	}	foodorderinfoBean.allPrice = jQuery('#allPriceEditor').val();
	if(!foodorderinfoBean.allPrice){
		$.ligerDialog.error("请输入总额!");
		return null;
	}	foodorderinfoBean.orderTime = jQuery('#orderTimeEditor').val();
	if(!foodorderinfoBean.orderTime){
		$.ligerDialog.error("请输入预定日期!");
		return null;
	}else{
		foodorderinfoBean.orderTime = new Date(Date.parse((foodorderinfoBean.orderTime+':00').replace(/-/g,   "/")));
	}
	foodorderinfoBean.registTime = jQuery('#registTimeEditor').val();
	if(!foodorderinfoBean.registTime){
		$.ligerDialog.error("请输入下单时间!");
		return null;
	}else{
		foodorderinfoBean.registTime = new Date(Date.parse((foodorderinfoBean.registTime+':00').replace(/-/g,   "/")));
	}
	foodorderinfoBean.state = jQuery('#stateEditor').val();
	if(!foodorderinfoBean.state){
		$.ligerDialog.error("请输入单号状态!");
		return null;
	}	foodorderinfoBean.mark = jQuery('#markEditor').val();
	foodorderinfoBean.payState = jQuery('#payStateEditor').val();
	if(!foodorderinfoBean.payState){
		$.ligerDialog.error("请输入支付状态!");
		return null;
	}	foodorderinfoBean.payType = jQuery('#payTypeEditor').val();
	
	return foodorderinfoBean;
};

var initFoodOrderInfoPage = function(){
	
	
	
	
	
	
	
	
	
	jQuery("#orderTimeEditor").ligerDateEditor({
		format:'yyyy-MM-dd hh:mm:ss',
		showTime:true,
	});
	
	jQuery("#registTimeEditor").ligerDateEditor({
		format:'yyyy-MM-dd hh:mm:ss',
		showTime:true,
	});
	
	
	
	
};

var bindFoodOrderInfoUpdateButtom = function(){
	jQuery('#updateEdit').unbind('click').click(function(){
		var foodorderinfoBean = getFoodOrderInfoBeanFromOpenPage();
		if(null != foodorderinfoBean){
			doSaveFoodOrderInfos([foodorderinfoBean]);
		}
	});
};
var bindFoodOrderInfoResetButtom = function(){
	jQuery('#resetEdit').unbind('click').click(function(){
		if(!initFoodOrderInfoBean){
			jQuery("#userIdEditor").val('');
			jQuery("#areaIdEditor").val('');
			jQuery("#shopIdEditor").val('');
			jQuery("#foodIdEditor").val('');
			jQuery("#numEditor").val('');
			jQuery("#onePriceEditor").val('');
			jQuery("#allPriceEditor").val('');
			jQuery("#orderTimeEditor").val('');
			jQuery("#registTimeEditor").val('');
			jQuery("#stateEditor").val('');
			jQuery("#markEditor").val('');
			jQuery("#payStateEditor").val('');
			jQuery("#payTypeEditor").val('');
		}else{
			if(!initFoodOrderInfoBean.userId){
				jQuery("#userIdEditor").val('');
			}else{
				jQuery("#userIdEditor").val(initFoodOrderInfoBean.userId);
			}
			if(!initFoodOrderInfoBean.areaId){
				jQuery("#areaIdEditor").val('');
			}else{
				jQuery("#areaIdEditor").val(initFoodOrderInfoBean.areaId);
			}
			if(!initFoodOrderInfoBean.shopId){
				jQuery("#shopIdEditor").val('');
			}else{
				jQuery("#shopIdEditor").val(initFoodOrderInfoBean.shopId);
			}
			if(!initFoodOrderInfoBean.foodId){
				jQuery("#foodIdEditor").val('');
			}else{
				jQuery("#foodIdEditor").val(initFoodOrderInfoBean.foodId);
			}
			if(!initFoodOrderInfoBean.num){
				jQuery("#numEditor").val('');
			}else{
				jQuery("#numEditor").val(initFoodOrderInfoBean.num);
			}
			if(!initFoodOrderInfoBean.onePrice){
				jQuery("#onePriceEditor").val('');
			}else{
				jQuery("#onePriceEditor").val(initFoodOrderInfoBean.onePrice);
			}
			if(!initFoodOrderInfoBean.allPrice){
				jQuery("#allPriceEditor").val('');
			}else{
				jQuery("#allPriceEditor").val(initFoodOrderInfoBean.allPrice);
			}
			if(!initFoodOrderInfoBean.orderTime){
				jQuery("#orderTimeEditor").val('');
			}else{
				var temp = new Date(initFoodOrderInfoBean.orderTime);
				jQuery("#orderTimeEditor").val(temp.formatLiger());
			}
			if(!initFoodOrderInfoBean.registTime){
				jQuery("#registTimeEditor").val('');
			}else{
				var temp = new Date(initFoodOrderInfoBean.registTime);
				jQuery("#registTimeEditor").val(temp.formatLiger());
			}
			if(!initFoodOrderInfoBean.state){
				jQuery("#stateEditor").val('');
			}else{
				jQuery("#stateEditor").val(initFoodOrderInfoBean.state);
			}
			if(!initFoodOrderInfoBean.mark){
				jQuery("#markEditor").val('');
			}else{
				jQuery("#markEditor").val(initFoodOrderInfoBean.mark);
			}
			if(!initFoodOrderInfoBean.payState){
				jQuery("#payStateEditor").val('');
			}else{
				jQuery("#payStateEditor").val(initFoodOrderInfoBean.payState);
			}
			if(!initFoodOrderInfoBean.payType){
				jQuery("#payTypeEditor").val('');
			}else{
				jQuery("#payTypeEditor").val(initFoodOrderInfoBean.payType);
			}
		}
	});
};



jQuery(function(){
	initFoodOrderInfoPage();
	bindFoodOrderInfoUpdateButtom();
	bindFoodOrderInfoResetButtom();
});